//
//  HZJBottomOfCell.swift
//  WeiBo
//
//  Created by 陈贵 on 15/9/12.
//  Copyright © 2015年 hzj. All rights reserved.
//

import UIKit


class HZJBottomOfCell: UIView {

    

    
    override init(frame: CGRect) {
        super.init(frame: frame)
        backgroundColor = UIColor(white: 0.95, alpha: 1)
        setUI()
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
/// 设置界面
    func setUI(){
        
        addSubview(forwardButton)
        addSubview(commentButton)
        addSubview(likeButton)
        
        //按钮宽度
        let count:CGFloat = 3
        let w = UIScreen.mainScreen().bounds.width / count

        
        //转发
//        addConstraint(NSLayoutConstraint(item: forwardButton, attribute: NSLayoutAttribute.Left, relatedBy: NSLayoutRelation.Equal, toItem: self, attribute: NSLayoutAttribute.Left, multiplier: 1, constant: 0))
//         addConstraint(NSLayoutConstraint(item: forwardButton, attribute: NSLayoutAttribute.Top, relatedBy: NSLayoutRelation.Equal, toItem: self, attribute: NSLayoutAttribute.Top, multiplier: 1, constant: 0))
//        addConstraint(NSLayoutConstraint(item: forwardButton, attribute: NSLayoutAttribute.Width, relatedBy: NSLayoutRelation.Equal, toItem: nil, attribute: NSLayoutAttribute.NotAnAttribute, multiplier: 1, constant: 0))
//        addConstraint(NSLayoutConstraint(item: forwardButton, attribute: NSLayoutAttribute.Height, relatedBy: NSLayoutRelation.Equal, toItem: self, attribute: NSLayoutAttribute.Height, multiplier: 1, constant: 0))
        forwardButton.translatesAutoresizingMaskIntoConstraints = false
        addTheConstraint(forwardButton, constant: 0)
        commentButton.translatesAutoresizingMaskIntoConstraints = false
        addTheConstraint(commentButton, constant: w)
        likeButton.translatesAutoresizingMaskIntoConstraints = false
        addTheConstraint(likeButton, constant: 2 * w)
        
    }
    
    
    private func addTheConstraint(item:AnyObject,constant: CGFloat){
        //按钮宽度
        let count:CGFloat = 3
        let w = UIScreen.mainScreen().bounds.width / count
        addConstraint(NSLayoutConstraint(item: item, attribute: NSLayoutAttribute.Left, relatedBy: NSLayoutRelation.Equal, toItem: self, attribute: NSLayoutAttribute.Left, multiplier: 1, constant: constant))
        addConstraint(NSLayoutConstraint(item: item, attribute: NSLayoutAttribute.Top, relatedBy: NSLayoutRelation.Equal, toItem: self, attribute: NSLayoutAttribute.Top, multiplier: 1, constant: 0))
        addConstraint(NSLayoutConstraint(item: item, attribute: NSLayoutAttribute.Width, relatedBy: NSLayoutRelation.Equal, toItem: nil, attribute: NSLayoutAttribute.NotAnAttribute, multiplier: 1, constant: w))
        addConstraint(NSLayoutConstraint(item: item, attribute: NSLayoutAttribute.Height, relatedBy: NSLayoutRelation.Equal, toItem: self, attribute: NSLayoutAttribute.Height, multiplier: 1, constant: 0))
    }
    
    
/// 懒加载
    private lazy var forwardButton:UIButton = UIButton(title: "  转发", imageName: "timeline_icon_retweet", color: UIColor.darkGrayColor(), fontSize: 14)
    private lazy var commentButton:UIButton = UIButton(title: "  评论", imageName: "timeline_icon_comment", color: UIColor.darkGrayColor(), fontSize: 14)
    private lazy var likeButton:UIButton = UIButton(title: "  赞", imageName: "timeline_icon_unlike", color: UIColor.darkGrayColor(), fontSize: 14)
    
    
    
}
